@extends('admin.public')

@section('content')
    <div class="col-md-12">
        <section class="panel panel-default">
            <header class="panel-heading bg-light no-border">
                <div class="clearfix">
                    @if($sort['image'])
                        <a href="#" class="pull-left b-3x m-r">
                            <img src="{{ $sort['image'] }}" alt="{{ $sort->name }}"
                                 style="width: auto;height: 55px">
                        </a>
                    @endif
                    <div class="clear">
                        <div class="h3 m-t-xs m-b-xs">
                            {{ $sort->name }}
                            @if( (bool)$sort->status )
                                <i class="fa fa-circle text-success pull-right text-xs m-t-sm" title="分类开启"></i>
                            @else
                                <i class="fa fa-circle text-dark pull-right text-xs m-t-sm" title="分类关闭"></i>
                            @endif
                        </div>
                        <small class="text-muted">{{ $sort->simpledescribe }}</small>
                    </div>
                </div>
            </header>
        </section>
    </div>

    <div class="col-md-12">
        <form data-validate="parsley" method="post" enctype="multipart/form-data">
            <input type="hidden" name="id" value="{{ $sort->id }}">
            {!! csrf_field() !!}
            <section class="panel panel-default">
                <header class="panel-heading">
                    {{ $chunk->name }} {{ $frame['title'] }}
                    <a href="{{ route('admin.sort.sort',$chunk->id) }}"
                       class="btn btn-xs btn-default pull-right">分类列表</a>
                </header>
                <div class="panel-body">
                    <p class="text-muted">
                        如需设置模块分类模版页面,请前往文件夹:<span
                                class="text-info">{{ pathinfo(config('app.sort_theme'))['dirname'] }}</span>,按指定格式(<span
                                class="text-info">{{ pathinfo(config('app.sort_theme'))['basename'] }}</span>)添加模版文件!
                    </p>
                    <div class="form-group pull-in clearfix">
                        <div class="col-sm-6">
                            <label>分类名称</label>
                            <input type="text" class="form-control parsley-validated" data-required="true" name="name"
                                   value="{{ $sort->name }}" placeholder="请填写分类名称">
                        </div>
                        <div class="col-sm-6">
                            <label>所属分类</label>
                            <div class="clearfix"></div>
                            <select style="width:100%" class="chosen-select" name="parent" disabled>
                                <option value="0" {{ 0==$sort->parent?'selected':'' }}>请选择分类,不选择则为顶级分类</option>
                                @foreach( $sorts as $k => $sortlv1 )
                                    <option value="{{ $sortlv1['id'] }}" {{ $sortlv1['id']==$sort->parent?'selected':'' }} >
                                        {{ $sortlv1['name'] }}
                                    </option>
                                    @if(!empty($sortlv1['children']))
                                        @foreach($sortlv1['children'] as $sortlv2 )
                                            <option style="text-indent: 20px"
                                                    value="{{ $sortlv2['id'] }}" {{ $sortlv2['id']==$sort->parent?'selected':'' }} >
                                                {{ $sortlv2['name'] }}
                                            </option>
                                            @if(!empty($sortlv2['children']))
                                                @foreach($sortlv2['children'] as $sortlv3 )
                                                    <option style="text-indent: 40px"
                                                            value="{{ $sortlv3['id'] }}" {{ $sortlv3['id']==$sort->parent?'selected':'' }} >
                                                        {{ $sortlv3['name'] }}
                                                    </option>
                                                    @if(!empty($sortlv3['children']))
                                                        @foreach($sortlv3['children'] as $sortlv4 )
                                                            <option style="text-indent: 60px"
                                                                    value="{{ $sortlv4['id'] }}" {{ $sortlv4['id']==$sort->parent?'selected':'' }} >
                                                                {{ $sortlv4['name'] }}
                                                            </option>
                                                        @endforeach
                                                    @endif
                                                @endforeach
                                            @endif
                                        @endforeach
                                    @endif
                                @endforeach
                            </select>
                        </div>
                    </div>
                    <div class="form-group pull-in clearfix">
                        <div class="col-sm-4">
                            <label>分类图片</label>
                            <div class="clearfix"></div>
                            <input type="file" class="filestyle" data-icon="false" data-classButton="btn btn-default"
                                   name="image"
                                   data-classInput="form-control inline v-middle input-s">
                        </div>
                        <div class="col-sm-4">
                            <label>分类模版</label>
                            <div class="clearfix"></div>
                            <select style="width:100%" class="chosen-select" name="theme">
                                @foreach($themes as $theme)
                                    <option value="{{ $theme }}" {{ $theme==$sort->theme?'selected':'' }}>{{ $theme }}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-sm-4">
                            <label>分类排序</label>
                            <div class="clearfix"></div>
                            <input class="slider slider-horizontal form-control" type="text" value="{{ $sort->xindex }}"
                                   name="xindex"
                                   data-slider-min="1" data-slider-max="100" data-slider-step="1"
                                   data-slider-value="{{ $sort->xindex }}"
                                   data-slider-orientation="horizontal">
                        </div>
                    </div>
                    <div class="form-group">
                        <label>摘要信息</label>
                        <textarea class="form-control" name="simpledescribe"
                                  placeholder="信息摘要 (如未填写,则引用详细信息中的前部分信息)">{{ $sort->simpledescribe }}</textarea>
                    </div>
                    <div class="form-group">
                        <label>详细信息</label>
                        <div id="describe" name="describe" type="text/plain" style="width: 100%;height: 300px;"></div>
                    </div>
                    <div class="checkbox i-checks">
                        <label>
                            <input type="checkbox" name="user_write" {{ (bool)$sort->user_write?'checked':'' }}
                            class="parsley-validated"><i></i> 勾选此项,即开启全部账号 添加/编辑/删除 权限
                            <small class="text-danger">( 注册用户只可编辑/删除自己添加的信息! )</small>
                        </label>
                    </div>
                    <div class="checkbox i-checks">
                        <label>
                            <input type="checkbox" name="status" {{ (bool)$sort->status?'checked':'' }}
                            class="parsley-validated"><i></i> 勾选此项,即开启此分类
                        </label>
                    </div>
                </div>
                <footer class="panel-footer text-right bg-light lter">
                    <button type="submit" class="btn btn-success btn-s-xs">保存</button>
                </footer>
            </section>
        </form>
    </div>
@endsection

@section('css')
    <link rel="stylesheet" href="/public/theme/js/chosen/chosen.css" type="text/css"/>
    <link rel="stylesheet" href="/public/theme/js/slider/slider.css" type="text/css"/>
@endsection

@section('js')
    <!-- slider -->
    <script src="/public/theme/js/slider/bootstrap-slider.js"></script>
    <!-- Chosen -->
    <script src="/public/theme/js/chosen/chosen.jquery.min.js"></script>
    <!-- parsley -->
    <script src="/public/theme/js/parsley/parsley.min.js"></script>
    <script src="/public/theme/js/parsley/parsley.extend.js"></script>
    <!-- tagsinput -->
    <script src="/public/theme/js/tagsinput/bootstrap-switch.js"></script>
    <script src="/public/theme/js/tagsinput/jquery.tagsinput.js"></script>
    <script src="/public/theme/js/tagsinput/form-component.js"></script>
    <!-- uediter -->
    <script src="/public/laravel-u-editor/ueditor.config.js"></script>
    <script src="/public/laravel-u-editor/ueditor.all.min.js"></script>
    <script src="/public/laravel-u-editor/lang/zh-cn/zh-cn.js"></script>
    <!-- file input -->
    <script src="/public/theme/js/file-input/bootstrap-filestyle.min.js"></script>
    <script>
        var ue = UE.getEditor('describe');
        ue.ready(function () {
            var content = {'data': {!! json_encode($sort->describe) !!}}
            ue.setContent(content.data);
        })
    </script>
@endsection